package cn.dslcode.security.common;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.Set;

@Data
@EqualsAndHashCode(of = "id")
public class SystemUser implements UserDetails {
    private Integer id;
    private String username;
    private String password;
    private boolean enabled;
    private Collection<? extends GrantedAuthority> authorities;

    private Set<Role> roles;

    public SystemUser(Integer userId, String username, String password, boolean enabled) {
        super();
        this.id = userId;
        this.username = username;
        this.password = password;
        this.enabled = enabled;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

}